package com.merge.skarabee;


import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

public class QRActivity extends Activity {
	
	private String mac;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_qr);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.qr, menu);
		return true;
	}
	
	
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
		IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
		if (scanResult != null) {
			
			/*String mac = scanResult.getContents().split(" ")[0];
			String pin = scanResult.getContents().split(" ")[1];
*/			
			String mac = scanResult.getContents();
			Intent resultIntent = new Intent();
			resultIntent.putExtra("MACAddress", mac);
			setResult(RESULT_OK, resultIntent);
		}
		// else continue with any other code you need in the method
		;
	}


	public void startScan(View view){
		IntentIntegrator integrator = new IntentIntegrator(this);
		integrator.initiateScan();
	}

}
